Skip to content

Conversation

@nerdrew
Copy link
Contributor

@nerdrew nerdrew commented Dec 19, 2025

No description provided.

Comment on lines -845 to -858
rescue FailoverError, CannotConnectError => error
error._set_config(config)
raise error
rescue ConnectionError => error
connect_error = CannotConnectError.with_config(error.message, config)
connect_error.set_backtrace(error.backtrace)
raise connect_error
rescue CommandError => error
if error.message.match?(/ERR unknown command ['`]HELLO['`]/)
raise UnsupportedServer,
"redis-client requires Redis 6+ with HELLO command available (#{config.server_url})"
else
raise
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why you moved these rescues. Now only the send_prelude call in connect is covered.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I closed this in favor of the other PR, but for posterity: I didn't move the rescues. The git diff just looks wonky. The actual diff just extracted the "send prelude" logic into a method that could be used in 2 different places.

https://github.com/nerdrew/redis-client/blob/aba5b7b468de5069150a1ff106ac42d9437f8d49/lib/redis_client.rb#L848-L872

assert_match(/WRONGPASS invalid username-password pair/, error.message)

# Correct password, but user disabled
backup.call("ACL", "SETUSER", "AzureDiamond", "<hunter2", ">trolilol", "off")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mutating an existing user, and trying to fix it in a rescue isn't good, as it may fail and leave the server in a state that fail other tests.

You can create a different user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can create a different user for this one. But for the tests around a disabled default user need to mutate the existing user. Do you have a preference how to do that? I can try to restore the default user after the test OR I can kill and restart the redis server after...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(These tests are the same between the 2 PRs, so even though this PR is closed, this is still relevant to the other PR.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Less mutation is always better. So if you can't absolutely eliminate them all it's OK, but we should still thrive to have as little as possible.

There is also the option of starting one more server with a disabled default user. Redis servers are quite cheap.

@nerdrew
Copy link
Contributor Author

nerdrew commented Dec 22, 2025

Closing in favor of #275

@nerdrew nerdrew closed this Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants